package kr.saeildamil.androidstudy.ch19;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

public class HandlerMessageObtain extends Activity {
	int mMainValue = 0;
	TextView mMain;
	TextView mBack;
	BackThreadObtain mThread;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_threadtest);
		
		mMain = (TextView)findViewById(R.id.ch19_threadtest_mainvalue);
		mBack = (TextView)findViewById(R.id.ch19_threadtest_backvalue);
		
		mThread = new BackThreadObtain(mHandler);
		mThread.setDaemon(true);
		mThread.start();
	}//end of oncreate
	
	public void mOnClick(View v){
		mMainValue++;
		mMain.setText("MainValue: " + mMainValue);
	}//end of mOnClick
	
	Handler mHandler = new Handler(){
		public void handleMessage(Message msg){
			if(msg.what==0){
				mBack.setText("Back Value : " + msg.arg1);
			}
		}
	};
}
